package com.ninong.ker.admin.rest;

import com.ninong.ker.admin.domain.FwTenant;
import com.ninong.ker.admin.service.FwTenantService;
import com.ninong.ker.admin.service.dto.FwTenantDTO;
import com.ninong.ker.common.tools.enums.BusinessEnum;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


import com.ninong.ker.common.annotation.log.Log;
import com.ninong.ker.common.annotation.perm.CmdAdmin;
import com.ninong.ker.common.response.CmdResponse;

import java.util.List;


/**
 * 系统-租户表
 *
 * @author 鸠摩智
 * @email cmd
 * @date 2021-05-27 10:48:51
 */
@RestController
@RequestMapping("/cmd/v1/tenant")
public class FwTenantResouces {

    @Autowired
    private FwTenantService tenantService;

    /**
     * 列表
     */
    @CmdAdmin({"admin", "tenant:list"})
    @PostMapping
    public ResponseEntity<CmdResponse> list(@RequestBody FwTenantDTO dto) {
        CmdResponse response = new CmdResponse();
        response.setData(tenantService.listPage(dto));
        return ResponseEntity.ok(response);
    }

    @PutMapping
    public ResponseEntity<CmdResponse> create(@RequestBody FwTenant entity) throws Exception {
        tenantService.create(entity);
        return ResponseEntity.ok(new CmdResponse());
    }

}
